package com.itheima.dao;


import com.itheima.pojo.Member;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

public interface MemberDao {

    /**
     * 6     * 查找用户是否是会员
     *
     * @param telephone
     */

    @Select("select * from t_member where phoneNumber=#{phoneNumber}")
    public Member findByTelephone(String telephone);

    /**
     * 添加会员
     *
     * @param member
     */
    @Insert("insert into t_member(id,fileNumber,name,sex,idCard,phoneNumber,regTime,password,email,birthday,remark) values(#{id},#{fileNumber},#{name},#{sex},#{idCard},#{phoneNumber},#{regTime},#{password},#{email},#{birthday},#{remark})")
    @SelectKey(statement = "select last_insert_id()", before = false, keyProperty = "id", resultType = Integer.class, keyColumn = "id")
    void add(Member member);

    /**
     * 根据月份查询会员数量
     *
     * @param
     */
    @Select("select count(id) from t_member where regTime <= #{date}")
    Integer findMemberCountByMonths(String date);

    //===========================================
    //根据日期统计会员数
    @Select("select count(id) from t_member where regTime = #{today}")
    Integer findMemberCountByDate(String today);

    //查询所有会员
    @Select("select count(id) from t_member")
    Integer findMemberTotalCount();

    //查询本周新增会员  //本月新增会员数
    @Select("select count(id) from t_member where regTime >= #{date}")
    Integer findMemberCountAfterDate(String date);



}
